<div class="search-box">
	<form class="search_form layui-form" lay-filter="brandcert_audit_search_form">
		<div class="layui-inline">
			<label class="layui-form-label layui-bg-blue">品牌名称</label>
			<div class="layui-input-inline">
				<input type="text" name="brand_name" autocomplete="off" class="layui-input">
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">审核状态</label>
			<div class="layui-input-inline">
				<select name="audit_state" lay-filter="audit_state" id="audit_state" lay-search>
					<option value="">全部</option>
					<option value="1">审核通过</option>
					<option value="2">等待审核</option>
					<option value="3">驳回审核</option>
				</select>
			</div>
		</div>
		<div class="layui-inline">
			<label class="layui-form-label">管理部门</label>
			<div class="layui-input-inline">
				<select name="department" lay-filter="department_search" id="department" lay-search>
					<option value="">请选择</option>
					<option value="采购部">采购部</option>
					<option value="产品部">产品部</option>
					<option value="市场部">市场部</option>
				</select>
			</div>
		</div>
		
		<div class="layui-inline">
			<div class="layui-input-inline">
				<input type="text" name="min_create_time" autocomplete="off" class="layui-input" placeholder="申请日期">
			</div>
			<div class="layui-input-inline">
				<input type="text" name="max_create_time" autocomplete="off" class="layui-input" placeholder="申请日期">
			</div>
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<input type="text" name="min_audit_time" autocomplete="off" class="layui-input" placeholder="审核日期">
			</div>
			<div class="layui-input-inline">
				<input type="text" name="max_audit_time" autocomplete="off" class="layui-input" placeholder="审核日期">
			</div>
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<input type="text" name="min_start_date" autocomplete="off" class="layui-input" placeholder="授权开始">
			</div>
			<div class="layui-input-inline">
				<input type="text" name="max_start_date" autocomplete="off" class="layui-input" placeholder="授权开始">
			</div>
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<input type="text" name="min_end_date" autocomplete="off" class="layui-input" placeholder="授权结束">
			</div>
			<div class="layui-input-inline">
				<input type="text" name="max_end_date" autocomplete="off" class="layui-input" placeholder="授权结束">
			</div>
		</div>
		<div class="layui-inline">
			<div class="layui-input-inline">
				<button type="button" id="brandcert_audit_search_btn"
					class="layui-btn layui-btn-normal layui-btn-sm layui-bg-red">搜 索</button>
			</div>
		</div>
		<div class="pack-up"></div>
	</form>
</div>
<table class="layui-hide" id="brandcert_audit_list" lay-filter="brandcert_audit_list"></table>

<div style="padding: 30px;display: none;" id="audit_box">
	<form class="layui-form" lay-filter="brandcert_audit" action="{:url('brandcert/setAudit')}">
		<input type="hidden" name="audit_id" class="layui-input" />
		<input type="hidden" name="audit_state"  class="layui-input"/>
		<div class="layui-form-item">
			<label class="layui-form-label">管理部门</label>
			<div class="layui-input-inline">
				<select name="department" lay-verify="required" lay-filter="department">
					<option value="">请选择</option>
					<option value="采购部">采购部</option>
					<option value="产品部">产品部</option>
					<option value="市场部">市场部</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item reason" style="display: none;">
			<label class="layui-form-label">驳回原因</label>
			<div class="layui-input-inline">
				<input type="text" name="reason" placeholder="" autocomplete="off" class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" class="layui-btn layui-btn-normal" lay-submit
					lay-filter="audit_brandcert" id="audit_brandcert">审核通过</button>
			</div>
		</div>
	</form>
</div>

<script>
	var brandcert_list_url = "{:url('brandcert/ajaxList')}";
	var brandcert_delete_url = "{:url('brandcert/ajaxDelete')}";
	var brandcert_setOpen_url = "{:url('brandcert/setOpen')}";
	var brandcert_cols = {$cols};
	var chk_supplier = false;
</script>
<script type="text/html" id="brandcert_audit_tool">
	<div class="layui-btn-group">
		<a class="layui-btn layui-btn-normal layui-btn-xs tap-nav" lay-event="edit" data-id="edit_brandcert_{{ d.id}}" data-url="{:url('brandcert/tplForm')}?id={{ d.id}}" data-title="修改证书"><i class="layui-icon layui-icon-edit"></i></a>
		{{# if(d.audit_state == 2){}}
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="auditHandle" data-type="1" data-id="{{ d.id}}" data-title="审核通过"><i class="layui-icon layui-icon-ok"></i></a>
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="auditHandle" data-type="0" data-id="{{ d.id}}" data-title="驳回申请"><i class="layui-icon layui-icon-close"></i></a>
		{{#}}}
		{{# if(d.audit_state == 1 && d.state_tips < 4){ }}
			{{# if(d.is_open == 0){ }}
			<a class="layui-btn layui-btn layui-btn-xs" lay-event="setOpen" data-id="{{ d.id}}" data-title="启用">启用</a>
			{{# } else{ }}
			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="setOpen" data-id="{{ d.id}}" data-title="停用">停用</a>
			{{# } }}
		{{# } }}
		<a class="layui-btn layui-btn-danger layui-btn-xs" style="display:none" lay-event="del" data-title="删除"><i class="layui-icon layui-icon-delete"></i></a>

	</div>
</script>
<script type="text/html" id="brandcertAuditToolbar">
	<div class="layui-btn-container">
		<a type="button" data-id="add_brandcert" data-url="{:url('brandcert/tplForm')}" data-title="品牌授权提交" class="layui-btn layui-btn-normal layui-btn-sm tap-nav" lay-event="addBrandcert"><i class="layui-icon layui-icon-add-1"></i>申请</a>
	</div>
</script>
<script type="text/html" id="audit_stateTpl">
{{# if(d.audit_state == 1){}}
	<div class="layui-anim circle layui-bg-green" data-title="通过">
		<i class="layui-icon layui-icon-radio"></i>
	</div>
	{{# } else if(d.audit_state == 2){ }}
		<div class="layui-anim circle layui-bg-orange" data-title="等待">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
		{{# } else {}}
			<div class="layui-anim circle layui-bg-red" data-title="驳回">
				<i class="layui-icon layui-icon-radio"></i>
			</div>
			{{# }}}
</script>
<script type="text/html" id="is_openTpl">
	{{# if(d.is_open == 1){}}
		<div class="layui-anim circle layui-bg-green" data-title="启用">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
	{{# } else {}}
		<div class="layui-anim circle layui-bg-red" data-title="停用">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
	{{# }}}
</script>
<script type="text/html" id="state_tipsTpl">
	{{# if(d.state_tips == 1){}}
		<div class="layui-anim circle layui-bg-green" data-title="正常">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
	{{# } else if(d.state_tips == 2){ }}
		<div class="layui-anim circle layui-bg-blue" data-title="90天内到期">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
	{{# } else if(d.state_tips == 3){ }}
		<div class="layui-anim circle layui-bg-orange" data-title="30天内到期">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
	{{# } else {}}
		<div class="layui-anim circle layui-bg-red" data-title="已过期">
			<i class="layui-icon layui-icon-radio"></i>
		</div>
	{{# }}}
</script>
<script>
	var createLink = (d)=>{
		let html = '';
		d.files.forEach((e)=>{
			html = html+'<a class="layui-btn layui-border-blue layui-btn layui-btn-xs" href="'+e.save_path+'" target="_blank">文件</a>';
		})
		return html;
	}
</script>

<script type="text/html" id="filesTpl">
	{{# 
		return createLink(d)
	}}
</script>
<script type="text/html" id="companyedTpl">
	{{# return d.companyed}}
</script>

<script src="/static/js/brandcert/audit.js" type="text/javascript" charset="utf-8"></script>
